package com.talos.framework.common.validation;


import com.talos.framework.common.annotation.NeedValue;
import com.talos.framework.common.util.collection.EmptyUtils;
import jakarta.validation.ConstraintValidatorContext;
import jakarta.validation.metadata.ConstraintDescriptor;
import org.hibernate.validator.constraintvalidation.HibernateConstraintValidator;
import org.hibernate.validator.constraintvalidation.HibernateConstraintValidatorInitializationContext;



public class NeedValueValidator implements HibernateConstraintValidator<NeedValue, Object> {

    @Override
    public void initialize(NeedValue constraintAnnotation) {

    }

    @Override
    public void initialize(ConstraintDescriptor<NeedValue> constraintDescriptor, HibernateConstraintValidatorInitializationContext initializationContext) {

    }

    @Override
    public boolean isValid(Object value, ConstraintValidatorContext context) {
        return EmptyUtils.hasValue(value);
    }

}

